﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
	class Program
	{
		static void Main(string[] args)
		{
			const char defaultValue = ' ';
			string s = "Language";
			char[] memory = { defaultValue, defaultValue, defaultValue, defaultValue, defaultValue, defaultValue, defaultValue, defaultValue };

			int pointer = 0;
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < s.Length; i++)
			{
				char ch = s[i];
				int diffCurrent = ch - memory[pointer];

				for (int j = 0; j < Math.Abs(diffCurrent); j++)
				{
					sb.Append(diffCurrent > 0 ? '+' : '-');
				}

				memory[pointer] = ch;

				if(i < s.Length - 1 && Math.Abs(s[i+1] - memory[pointer]) < Math.Abs(s[i+1] - memory[pointer+1]))
				{
					memory[pointer + 1] = memory[pointer];
					sb.Append('%');
				}

				if (i < s.Length - 1)
				{
					pointer++;
					sb.Append('>');
				}
			}
			sb.Append('@');

			Console.WriteLine(sb.ToString());
			Console.WriteLine(sb.Length);
			Console.ReadLine();
		}
	}
}